<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>call、apply、bind函数</title>
</head>

<body>
    <script>
        //使用call、apply、bind函数改变函数中的this指向

        function fn(a, b) {
            console.log(this);
            console.log(a + b);
        }
        var o = {
            name: 'zs'
        }
        fn(1, 2);
        // fn.call(o, 1, 2);
        // fn.apply(o, [1, 2]);
        //bind方法调用一个函数，①并不会立即执行，而是将函数返回
        var result = fn.bind(o, 1, 2);
        result();  //②再来调用返回的函数


    </script>
</body>

</html>